import { cloud } from '@hw-agconnect/cloud-server';
import { sys_log } from './sys_log'; // BookInfo是Server Model

// default是BookInfo对象类型使用的存储区名
const collection = cloud.database({ zoneName: 'default' }).collection(sys_log);


export class SysLogFunc {
  query() {
    return collection.query().get();
  }


  upset(sys_logs: sys_log[]) {
    return new Promise((resolve, reject) => {
      collection.upsert(sys_logs.map(logData => sys_log.parseFrom(logData)))
        .then(result => resolve({ result }))
        .catch(err => reject(err))
    });
  }
}
